package com.hh.controller;

import com.hh.dto.ResultDTO;
import com.hh.until.MailUtil;
import com.hh.until.Tool;
import com.hh.vo.ApplyVO;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/back")
public class SendEmailController {

    @PostMapping("/sendEmail")
    public ResultDTO sendEmail(ApplyVO applyVO) {
        applyVO.setEmail(Tool.nullToStr(applyVO.getEmail()));
        applyVO.setReply(Tool.nullToStr(applyVO.getReply()));

        try {
            MailUtil.sendMsg(applyVO.getEmail(), "申请回复", applyVO.getReply());
            return ResultDTO.builder().code(0).msg("邮件发送成功").build();
        } catch (Exception e) {
            e.printStackTrace();
        }
        return null;
    }
}
